package section3_4;

import java.util.concurrent.TimeUnit;

/**
 * Created by Hyman on 2017/6/4.
 *
 * 参与者类
 */
public class Participant implements Runnable {

    /**
     * 视频会议对象
     */
    private VideoConference conference;
    /**
     * 参与者的名称（仅仅是为了记录使用）
     */
    private String name;

    public Participant(VideoConference conference, String name) {
        this.conference = conference;
        this.name = name;
    }

    @Override
    public void run() {

        long duration = (long)(Math.random() * 10);

        try {
            TimeUnit.SECONDS.sleep(duration);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        conference.arrive(name);

    }
}
